<?php
/*
	插件链接选择页面
*/
defined('BY_JYA') or exit('error');
//系统链接获取接口
$return=array();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$tabs=array(
	array('op'=>'system','plugin'=>'core','action'=>'tools.link','title'=>'系统页面链接'),
	array('op'=>'list','title'=>'插件页面'),
	array('op'=>'merch','title'=>'商户分类'),
);
if($_RQ['op']=='list'){
	$return['list']=array(
		array('title'=>'首页','url'=>'jy_weishopmeituan/index//current_plugin=jy_weishopmeituan'),
		array('title'=>'搜索','icon'=>'icon-compass','url'=>'jy_weishopmeituan/search/'),
		array('title'=>'订单','icon'=>'icon-manageorder','url'=>'jy_weishopmeituan/orderlist/'),
		array('title'=>'我的','icon'=>'icon-wo1','url'=>'jy_weishopmeituan/myhome/'),
	);
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'标题','type'=>'string'),
			array('name'=>'url','title'=>'H5路径','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'url','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='merch'){
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if(!empty($_RQ['catename'])){
		$params['catename like']='%'.trim($_RQ['catename']).'%';
		$return['params']['catename']=$_RQ['catename'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total=0;
	$list=pdo_getslice('jy_merch_category',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['url']='jy_weishopmeituan/merchlist//cid='.$item['id'];
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'list'=>array(
			array('name'=>'catename','title'=>'分类标题','type'=>'string'),
			array('name'=>'url','title'=>'链接地址','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'url','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'catename','add'=>false),
	);
	$return['htmls']=$htmls;
	exi($return);
}
?>